home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr47 / asmlib40.zip / SYSTEM.DOC < prev    next >
Text File  |  1995-02-20  |  29KB  |  983 lines

  1.  
  2. *****************************  SYSTEM  *************************************
  3.  
  4. ASMLIB system subroutines Copyright (C) 1991 - 1995 Douglas Herr
  5. all rights reserved
  6.  
  7.  
  8. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  9.  
  10. ALLOCDOS:    allocate memory block from DOS memory
  11. Source:      allocdos.asm
  12.  
  13. Call with:   DX:AX = bytes requested
  14.              Before using AllocDOS, you must release unused memory with
  15.              MEMINIT (see STARTUP.ASM).  Memory allocated with AllocDOS
  16.              may be released with DOS function 49h
  17. Returns:     if CF = 0, BX = segment address of allocated memory block
  18.              if CF = 1, AH = AL = DOS error code
  19. Uses:        AX, BX, flags
  20. Example:
  21.  
  22. include asm.inc
  23.  
  24. public  myprog
  25. extrn   allocdos:proc
  26.  
  27. .data
  28. dseg    dw ?          ; storage for segment address of allocated memory
  29. bytes   dd 100000     ; about 100k
  30.  
  31. .code
  32. myprog  proc
  33. ; program fragment assumes DS:@data
  34.         .
  35.         .
  36.         .
  37.         mov     ax,word ptr bytes
  38.         mov     dx,word ptr bytes+2   ; DX:AX = bytes requested
  39.         call    allocdos
  40.         jc      alloc_error
  41.         mov     dseg,bx
  42.  
  43.  
  44. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  45.  
  46. BREAKTRAP:   initialize Ctrl+Break trap
  47. BREAKRELEASE:restore previous Ctrl+Break handler
  48. Source:      break.asm
  49.  
  50. BREAKFLAG:   public byte in DGROUP, indicating Ctrl+Break key press
  51. Source:      $flags.asm
  52.  
  53. Call with:   no parameters
  54.              BreakTrap uses well-behaved methods to trap Ctrl+Break,
  55.              Ctrl+C and Ctrl-Alt-Del key sequences.  When one of these
  56.              key combinations is pressed, ASMLIB's break trap sets the
  57.              public flag "breakflag" in the data area.  BreakRelease
  58.              de-activates ASMLIB's break trap, restoring the previous
  59.              Ctrl+Break handler.  BreakFlag = 0 until a monitored key
  60.              combination is pressed, at which time breakflag is set
  61.              equal to 1.  If you use BreakTrap, you MUST call BreakRelease
  62.              before the end of your program, or you will find yourself
  63.              reaching for the Big Red Switch.  See STARTUP.ASM.
  64. Returns:     nothing
  65. Uses:        nothing
  66. Example:     see STARTUP.ASM
  67.  
  68.  
  69.  
  70. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  71.  
  72. COLOR16:     calculate color value for palette register
  73. Source:      color16.asm
  74.  
  75. Call with:   DS:[BX] pointing to red value (0-3), green value (0-3)
  76.              and blue value (0-3)
  77.              Assumes DS:@data; see also Palette16
  78. Returns:     AH = color value for 16-color palette register
  79. Uses:        AH
  80. Supports:    VGA 16-color modes (text or graphics)
  81.              EGA 16-color modes, except with CGA monitor
  82. Example:
  83.  
  84. .data
  85. c16     db 3                  ; brightest red
  86.         db 1                  ; dim green
  87.         db 0                  ; no blue
  88.  
  89. .code
  90. ; program fragment assumes DS:@data
  91.         .
  92.         .
  93.         .
  94.         lea   bx,c16
  95.         call  color16
  96.  
  97.  
  98.  
  99. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  100.  
  101. DOSFREE:     deteremines DOS memory available
  102. Source:      dosfree.asm
  103.  
  104. Call with:   no parameters
  105. Returns:     DX:AX = bytes available in conventional memory space
  106.              For best results, release excess memory with MEMINIT
  107.              (next page; also see STARTUP.ASM).
  108. Uses:        DX, AX
  109. Example:
  110.         call   dosfree
  111.  
  112.  
  113. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  114.  
  115. EXENAME:     determine the full path and filename of the executing program
  116. Source:      exename.asm (strlen.asm)
  117.  
  118. Call with:   ES = PSP segment (see STARTUP.ASM)
  119. Returns:     ES:[BX] pointing to the the name of the executing program,
  120.              including drive and full path, CX = length of the filename.
  121.              The filename returned is an ASCIIZ string, and may be mixed
  122.              upper- and lower-case characters.
  123. Uses:        ES, BX, CX; all other registers and flags are saved.
  124. Example:
  125.  
  126. include asm.inc
  127.  
  128. extrn   exename:proc
  129.  
  130. .data
  131. extrn   pspseg:word
  132.  
  133. .code
  134. ; program fragment assumes DS:@data
  135.         .
  136.         .
  137.         .
  138.         mov   es,pspseg
  139.         call  exename         ; string returned at ES:[BX] can be
  140.                               ; copied to heap with STRNDUP
  141.  
  142.  
  143.  
  144. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  145.  
  146. EXESIZE:     determine size of .EXE program
  147.              NOTE: not in ASMTINY.LIB or 286TINY.LIB
  148. Source:      exesize.asm
  149.  
  150. Call with:   DS:[DX] pointing to ASCIIZ .EXE filename
  151. Returns:     if CF = 1, AX = DOS error code
  152.                         if AX = 0, not an EXE-format file
  153.              if CF = 0, DX:AX = bytes in .EXE file loaded by DOS program
  154.                         loader
  155.              Note that additional data may be copied to the end of a DOS
  156.              .EXE file with the DOS COPY /B command.  This is handy for
  157.              help screens or other such data that you want to keep with
  158.              the .EXE file, but that you don't want to be loaded in memory
  159.              with the program.  If you do copy additional data to the .EXE
  160.              file, EXESize will report only the portion of the file loaded
  161.              in RAM by the DOS program loader, while FSize (in DISK.DOC)
  162.              reports the entire file size.
  163. Uses:        AX, DX, flags
  164. Example:
  165.  
  166. ;
  167. ; code used to test EXEsize
  168. ;
  169. include asm.inc
  170.  
  171. public  testcode
  172. extrn   exename:proc, exesize:proc
  173. extrn   strndup:proc, i4tostr:proc
  174. extrn   tprint:proc, getkey:proc
  175.  
  176. .data
  177. extrn   pspseg:word
  178. space   db 20 dup(0)
  179.  
  180. .code
  181. testcode        proc
  182.         mov     es,pspseg
  183.         call    exename         ; get name of this program
  184.         call    strndup         ; copy to near heap
  185.                                 ; startup code was assembled with /DHEAP
  186.         mov     dx,bx           ; DS:[DX] -> EXE filename
  187.         call    exesize         ; DX:AX = EXE program size
  188.         lea     si,space
  189.         call    i4tostr         ; convert to ASCIIZ string
  190.         xor     dx,dx           ; point to UL corner of screen
  191.         mov     ah,12           ; "can't miss it" color
  192.         call    tprint          ; print it
  193.         call    getkey          ; don't scroll off screen yet
  194.         ret                     ; go back to calling code
  195. testcode        endp
  196.         end
  197.  
  198.  
  199. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  200.  
  201. FARALLOC:    allocate memory from a far heap
  202. Source:      farheap.asm
  203.  
  204. Call with:   ES = segment address of far heap
  205.              AX = requested block size
  206. Returns:     if CF = 1, insufficient memroy available in heap
  207.              if CF = 0, ES:[BX] = starting address of allocated memory
  208. Uses:        BX, flags
  209. Example:     see FarInit
  210.  
  211.  
  212. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  213.  
  214. FARFREE:     releases far heap memory previously allocated
  215. Source:      farheap.asm
  216.  
  217. Call with:   ES:[BX] pointing to memory block to be released
  218. Returns:     nothing
  219. Uses:        AX, BX, flags
  220. Example:     mov   es,heap_seg
  221.              mov   bx,pointer
  222.              call  farfree
  223.  
  224.  
  225. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  226.  
  227. FARINIT:     initializes a far heap
  228. Source:      farheap.asm
  229.  
  230. Call with:   ES = segment address of memory block to be managed by ASMLIB's
  231.              far heap manager
  232.              AX = size of memory block in bytes (2 < bytes < 32768)
  233.              FarInit assumes that the memory block begins at ES:[0].
  234.              Any number of far heaps may be used if memory is available.
  235. Returns:     if CF = 0, successful; if CF = 1, AX is out of range.
  236. Uses:        flags
  237. Example:
  238.  
  239. include asm.inc
  240.  
  241. extrn   allocdos:proc, farinit:proc
  242.  
  243. .data
  244. heap_seg        dw ?
  245.  
  246. .code
  247.         .
  248.         .
  249.         .
  250.         mov     ax,32767
  251.         xor     dx,dx           ; allocate 32k from DOS memory
  252.         push    ax
  253.         call    allocdos
  254.         mov     heap_seg,bx     ; segment address of allocated block
  255.         pop     ax              ; size of block
  256.         jc      not_enough_dos  ; insufficient memory available
  257.         mov     es,heap_seg
  258.         call    farinit         ; initialize this block
  259.         .
  260.         .
  261.         mov     ax,125          ; get 125 bytes from far heap
  262.         mov     es,heap_seg     ; heap address
  263.         call    faralloc        ; get far memory; returned at ES:[BX]
  264.         jc      not_enough_heap
  265.  
  266.  
  267.  
  268. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  269.  
  270. FARREALLOC:  re-sizes a block of memory in a far heap
  271. Source:      farheap.asm
  272.  
  273. Call with:   ES:[BX] = original pointer to memory block
  274.              AX = new byte size
  275. Returns:     if successful, CF = 0, ES:[BX] points to new block
  276.              if not successful, CF = 1
  277. Uses:        BX, flags
  278. Example:     mov    es,heap_seg
  279.              mov    bx,pointer
  280.              mov    ax,newsize
  281.              call   farrealloc
  282.  
  283.  
  284. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  285.  
  286. FINDMONO:    detects a monochrome-compatible video card
  287.              this is handy in 2-monitor systems.
  288. Source:      findmono.asm (a$herc.asm, isega.asm, $6845.asm)
  289.  
  290. Call with:   no parameters
  291. Returns:     if CF = 1, no monochrome monitor
  292.              if CF = 0, AX = monitor code
  293.               0 = MDA
  294.               0101h = EGA monochrome
  295.               0301h = VGA monochrome
  296.               128 = Hercules or clone
  297.               144 = Hercules Graphics Card plus
  298.               208 = Hercules InColor
  299. Uses:        AX, CF
  300. Supports:    MDA, EGA & VGA MONO, HGC, HGC+, InColor
  301. Example:     call  findmono
  302.              jc    no_monochrome
  303.  
  304.  
  305.  
  306. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  307.  
  308. FLOPPIES:    determine the number of floppy disk drives intalled
  309. Source:      floppies.asm
  310.  
  311. Call with:   no parameters
  312. Returns:     AX = number of floppy drives
  313. Uses:        AX; all other registers and flags are saved
  314. Example:
  315.  
  316. .model medium
  317.  
  318. public  myproc
  319. extrn   floppies:proc
  320.  
  321. .code
  322. myproc  proc
  323.         .
  324.         call   floppies
  325.  
  326.  
  327.  
  328. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  329.  
  330. FLOPPYTYPE:  determine the type of floppy disk drives intalled
  331. Source:      floptype.asm
  332.  
  333. Call with:   DL = drive number (0 = drive A:)
  334. Returns:     AX = floppy drive type
  335.               0 = invalid drive number
  336.               1 = 360k
  337.               2 = 1.2M
  338.               3 = 720k
  339.               4 = 1.44M
  340. Uses:        AX, flags
  341. Example:
  342.  
  343. .model medium
  344.  
  345. public  myproc
  346. extrn   floppytype:proc
  347.  
  348. .data
  349. drive_number   db 0
  350.  
  351. .code
  352. myproc  proc
  353.         .
  354.         mov    dl,drive_number
  355.         call   floppytype
  356.         or     ax,ax
  357.         jz     bad_drive_number
  358.  
  359. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  360.  
  361. GETCPU:      detects cpu type
  362. Source:      getcpu.asm
  363.  
  364. Call with:   no parameters
  365. Returns:     AX = 0 if 8086/8088
  366.              AX = 1 if 80186/80188
  367.              AX = 2 if 80286
  368.              AX = 3 if 386 (SX or DX)
  369.              AX = 4 if 486 (SX or DX)
  370. Uses:        AX
  371. Example:     call   getcpu
  372.  
  373.  
  374.  
  375. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  376.  
  377. GETCRT:      determines active monitor type
  378. Source:      getcrt.asm (a$herc.asm, isevga.asm)
  379.  
  380. Call with:   no parameters
  381. Returns:     AX = code for active video system
  382.              CGA = -1
  383.              MDA = 0
  384.              EGA mono = 0100h
  385.              VGA mono = 0300h
  386.              EGA color = 1
  387.              MCGA = 2
  388.              VGA color = 3
  389.              HGC = 128
  390.              HGC+ = 144
  391.              InColor = 208
  392.              Note: GetCRT may be re-assembled with the /DNOHERC switch
  393.              to eliminate code which detects Hercules equipment
  394. Uses:        AX
  395. Supports:    CGA, MCGA, MDA, HGC, HGC+, InColor, EGA, VGA
  396. Example:     call    getcrt
  397.  
  398.  
  399.  
  400. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  401.  
  402. HALLOC:      allocates memory from near heap
  403. Source:      heap.asm
  404.  
  405. Call with:   AX = bytes requested; assumes DS:@data
  406.              heap must be initialized with MEMINIT
  407. Returns:     if space available:
  408.              BX = near pointer for allocated data
  409.              if space not available:
  410.              CF = 1
  411. Uses:        AX, BX, flags
  412. Example:     mov   ax,bytes
  413.              call  halloc
  414.              jc    no_memory       ; check to see if there was enough space
  415.  
  416.  
  417. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  418.  
  419. HFREE:       releases heap memory previously allocated
  420. Source:      heap.asm
  421.  
  422. Call with:   BX = near pointer to memory block; assumes DS:@data
  423. Returns:     nothing
  424. Uses:        flags
  425. Example:     mov   bx,pointer
  426.              call  hfree
  427.  
  428.  
  429.  
  430. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  431.  
  432. HMAX:        determines largest free block in asmlib's near heap
  433. Source:      heap.asm
  434.  
  435. Call with:   no parameters
  436. Returns:     AX = block size in bytes
  437.              AX = -1 if the heap has not been initialized
  438. Uses:        AX
  439. Example:     call   hmax
  440.  
  441.  
  442.  
  443. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  444.  
  445. HREALLOC:    re-sizes a block of memory in the near heap
  446. Source:      heap.asm
  447.  
  448. Call with:   BX = original pointer to memory block
  449.              AX = new byte size
  450. Returns:     if successful, CF = 0, BX = new block pointer
  451.              if not successful, CF = 1
  452. Uses:        BX, flags
  453. Example:     mov    bx,pointer
  454.              mov    ax,newsize
  455.              call   hrealloc
  456.  
  457.  
  458. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  459.  
  460. ISANSI:      determines if ANSI or compatible is loaded and active
  461. Source:      isansi.asm
  462.  
  463. Parameters:  none
  464. Returns:     CF = 1 if no ANSI device driver loaded and active
  465.              CF = 0 if ANSI loaded and active
  466. Uses:        CF
  467. Example:     call   isansi         ; let's see if ansi.sys is loaded
  468.              jc     no_ansi        ; jump if not
  469.  
  470.  
  471.  
  472. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  473.  
  474. ISATT:       determines if an ATT 6300-type display card is installed
  475.              this equipment is like a CGA except that it has an additional
  476.              640 x 400 2-color graphics mode (mode 40h)
  477. Source:      isatt.asm ($6845.asm, isevga.asm)
  478.  
  479. Call with:   no parameters
  480. Returns:     if CF = 1, ATT 6300 display not present
  481.              if CF = 0, ATT 6300 display is installed
  482. Uses:        flags
  483. Example:
  484.  
  485. include asm.inc
  486.  
  487. public  cgamode
  488.  
  489. extrn   isatt:proc
  490.  
  491. .code
  492. cgamode proc
  493.         mov     ax,06h             ; default: set CGA mode
  494.         call    isatt              ; see if mode 40h is available
  495.         jc      set_mode           ; nope
  496.         mov     ax,40h             ;  use ATT 6300 mode 40h
  497. set_mode:
  498.         push    bp                 ; required by old PC BIOS
  499.         int     10h                ; use BIOS to set mode
  500.         pop     bp
  501.         ret
  502. cgamode endp
  503.         end
  504.  
  505.  
  506. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  507.  
  508. ISEVGA:      determines if an EGA or VGA is installed
  509. Source:      isevga.asm
  510.  
  511. Call with:   no parameters
  512. Returns:     if CF = 1, no EGA or VGA
  513.              if CF = 0
  514.                DX = video memory in kbytes
  515.                AL = monitor type
  516.                 AL = -1 if monitor is CGA
  517.                 AL = 0 if monitor is monochrome
  518.                 AL = 1 if monitor is EGA or better
  519.  
  520.                AH = EGA/VGA flag
  521.                 AH = 1 if EGA
  522.                 AH = 3 if VGA
  523.  
  524. Uses:        AX, DX, CF
  525. Example:     call   isevga
  526.              jc     no_evga
  527.  
  528.  
  529.  
  530. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  531.  
  532. ISHERC:      determines if a Hercules card or compatible is installed
  533.              and if so, determines if it is the active video system.
  534. Source:      isherc.asm (a$herc.asm)
  535.  
  536. Call with:   no parameters
  537. Returns:     if CF = 1, no Hercules or compatible installed
  538.              if CF = 0, AX = Hercules model
  539.              128 = Hercules Graphics Card or compatible; active
  540.              144 = Hercules Graphics Card Plus; active
  541.              208 = Hercules InColor card; active
  542.              -128 = Hercules Graphics Card or compatible; not active
  543.              -144 = Hercules Graphics Card Plus; not active
  544.              -208 = Hercules InColor card; not active
  545. Uses:        AX, CF; all other flags and registers are saved
  546. Example:     call  isherc
  547.              jc    no_herc
  548.  
  549.  
  550.  
  551. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  552.  
  553. ISMOUSE:     determines if a mouse is installed
  554. Source:      ismouse.asm ($flags.asm)
  555.  
  556. Parameters:  none
  557. Returns:     AX = number of mouse buttons
  558.              AX = 0 if no mouse or mouse driver installed
  559. Uses:        AX
  560. Example:
  561.  
  562. include  asm.inc
  563.  
  564. .code
  565.        .
  566.        .
  567.        .
  568.        call    ismouse
  569.        or      ax,ax
  570.        jz      no_mouse
  571.  
  572.  
  573.  
  574. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  575.  
  576. ISSEVGA:     determines if a Super EGA or Super VGA is installed
  577. Source:      issevga.asm ($sega.asm, $svga.asm)
  578.  
  579. Parameters:  none
  580. Returns:     if CF = 1, no Super EGA or Super VGA recognized by ASMLIB
  581.  
  582.              if CF = 0
  583.  
  584.               AH = 1: Super EGA
  585.               AH = 3: Super VGA
  586.  
  587.               AL = 1 if Paradise
  588.               AL = 2 if Everex
  589.               AL = 3: Tseng VGA chipset
  590.               AL = 4: Oak Technologies
  591.               AL = 5: Western Digital (Paradise) OEM
  592.               AL = 6: ATI
  593.               AL = 7: Compaq
  594.               AL = 8: NCR
  595.               AL = 9: Trident
  596.               AL =10: Video7
  597.               AL =11: Genoa
  598.               AL =12: Cirrus
  599.               AL =13: Chips & Technologies
  600.               AL =14: Tseng 4000
  601.               AL =15: Ahead A
  602.               AL =16: Ahead B
  603.               AL =17: Trident 8900
  604.  
  605.              See also IsEVGA
  606. Uses:        AX, CF
  607. Example:     call   issevga
  608.              jc     no_superevga
  609.  
  610. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  611.  
  612. ISVM86:      determines if 32-bit processor is in V86 mode
  613. Source:      isvm86.asm (getcpu.asm)
  614.  
  615. Parameters:  none
  616.              V86 is used by Expanded Memory device drivers such as QEMM
  617.              and EMM386 to provide Expanded Memory using extended memory
  618.              of 32-bit systems such as 386 (DX and SX) and 486 (DX and SX)
  619.              computers
  620. Returns:     AX = processor type (see GetCPU)
  621.              if CF = 0, 32-bit processor in V86 mode
  622.              if CF = 1, no 32-bit processor or not V86 mode
  623. Uses:        AX, flags
  624. Example:
  625.  
  626. include asm.inc
  627.  
  628. public  test_for_vm86
  629. extrn   isvm86:proc
  630.  
  631. .data
  632. vm86    db 'VM86 detected',0Dh,0AH,'$'
  633. notvm86 db 'VM86 not detected',0Dh,0AH,'$'
  634.  
  635. .code
  636. test_for_vm86   proc
  637.         lea     dx,vm86
  638.         call    isvm86
  639.         jnc     exit
  640.         lea     dx,notvm86
  641. exit:   mov     ah,9           ; DOS function: display string
  642.         int     21h
  643.         ret
  644. test_for_vm86   endp
  645.  
  646.  
  647.  
  648. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  649.  
  650. KBDTYPE:     determines keyboard type and function support
  651. Source:      kbdtype.asm
  652.  
  653. Input:       none
  654. Returns:     AH = 10h if advanced function support
  655.                   00h if standard function support
  656.              AL = 01h if 101-key keyboard
  657.                   00h if 83/84-key keyboard
  658. Uses:        AX, flags
  659. Example:
  660.  
  661. extrn   kbdtype:proc
  662.  
  663. .code
  664.  
  665.         .
  666.         .
  667.         .
  668.  
  669. ; determine if I can use function keys F11 and F12
  670.  
  671.         call    kbdtype
  672.         cmp     ax,1001h
  673.         je      short use_all_Fkeys
  674. ;
  675. ; use 10 function keys
  676. ;
  677.         .
  678.         .
  679.         .
  680.  
  681. ;
  682. ; use 12 function keys
  683. ;
  684. Use_all_Fkeys:
  685.         .
  686.         .
  687.  
  688.  
  689.  
  690. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  691.  
  692. MATHCHIP:    determines if 80x87 math coprocessor is installed
  693. Source:      mathchip.asm
  694.  
  695. Parameters:  none
  696. Returns:     AX = code for 80x87 model
  697.              0 = not installed
  698.              1 = 8087
  699.              2 = 287
  700.              3 = 387 (DX or SX)
  701.              4 = 487 (486DX or 487SX)
  702.              If the coprocessor is present, it is initilaized by MathChip.
  703. Uses:        AX, all 80x87 registers
  704. Example:     call  mathchip
  705.  
  706.  
  707.  
  708. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  709.  
  710. MEMINIT:     initializes dynamic memory allocation
  711. Source:      meminit.asm
  712.  
  713. Call with:   AX = number of bytes to be managed in near heap
  714.              2 <=bytes<= 32767
  715.              BX = near pointer to memory block to be managed
  716.              assumes  DS:@data
  717.              If BX = -1, MEMINIT will allocate the near heap at the end
  718.              of the program's initialized code and data.  AX returns the
  719.              number of bytes actually allocated to the near heap.  For
  720.              smaller programs you can usually use meminit's self-allocating
  721.              code; for larger programs you may need to reserve space in
  722.              your data segment for the heap.
  723. Returns:     CF = 0 if ok, CF = 1 if bad parameter (bytes too small or
  724.              too large)
  725. Uses:        AX, flags
  726. Example 1:
  727.  
  728. ; this example reserves 32k in DGROUP for the near heap
  729.  
  730. .data
  731. heap   db  32767 dup(0)
  732.  
  733. .code
  734.        mov    ax,@data
  735.        mov    ds,ax
  736.        assume ds:@data
  737.        mov    ax,32767
  738.        lea    bx,heap
  739.        call   meminit
  740.  
  741.  
  742.  
  743. Example 2:
  744.  
  745. ; this example allocate DGROUP space for the heap beyond the end of the
  746. ; program's initilaized code and data
  747. ; I use a debugger to examine AX returned by MEMINIT to make sure the
  748. ; heap is large enough.  NOTE: Borland's Turbo Debugger (TD) does not
  749. ; like MEMINIT's self-destructing code.  Set a breakpoint after your
  750. ; call to MEMINIT and run the program (F9) to that point.  If you try
  751. ; to trace through MEMINIT you'll end up reaching for the Big Red Switch.
  752.  
  753. .code
  754.        mov    ax,@data
  755.        mov    ds,ax
  756.        assume ds:@data
  757.        mov    ax,32767
  758.        mov    bx,-1
  759.        call   meminit
  760.  
  761.  
  762. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  763.  
  764. MOUSEINIT:   initializes mouse driver if mouse present
  765. Source:      mouseini.asm
  766.  
  767. MOUSEFLAG:   public byte in DGROUP indicating mouse buttons
  768. Source:      $flags.asm
  769.  
  770. Parameters:  assumes DS:@data
  771. Returns:     if mouse installed, ZF = 0 and AX = number of mouse buttons
  772.              also updates mouseflag
  773.              if no mouse, ZF = 1 and AX = 0
  774. Uses:        AX, flags
  775. Example:
  776.  
  777. include asm.inc
  778.  
  779. extrn   mouseinit:proc
  780.  
  781. .code
  782. ; program fragment assumes DS:@data
  783.         .
  784.         .
  785.         .
  786.         call    mouseinit
  787.         jz      no_mouse
  788.  
  789.  
  790.  
  791. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  792. MOUSETYPE:   determine mouse type (bus, serial, PS/2, etc.)
  793. Source:      mousetyp.asm
  794.  
  795. Call with:   no parameters
  796.              assumes mouse driver has been loaded (see IsMouse)
  797. Returns:     AX = mouse type
  798.               0 = mouse driver error
  799.               1 = bus mouse
  800.               2 = serial mouse
  801.               3 = InPort mouse
  802.               4 = PS/2 mouse
  803.               5 = HP mouse
  804. Uses:        AX, flags
  805. Example:
  806.  
  807. include asm.inc
  808.  
  809. extrn   mousetype:proc
  810. extrn   ismouse:proc
  811.  
  812. .code
  813.         .
  814.         .
  815.         .
  816.         call   ismouse
  817.         or     ax,ax        ; is a mouse installed?
  818.         jz     no_mouse
  819.         call   mousetype    ; what kind of mouse?
  820.         or     ax,ax
  821.         jz     mouse_error
  822.         .
  823.         .
  824.  
  825.  
  826.  
  827. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  828.  
  829. MSAVE:       save mouse state
  830. Source:      msave.asm (allocdos.asm)
  831.  
  832. MRESTORE:    restore previously saved mouse state
  833. Source:      msave.asm (allocdos.asm)
  834.  
  835.              MSave and MRestore are handy when you have installed a
  836.              mouse event handler and you will be using the SYSTEM command,
  837.              where some other program may reset or otherwise change the
  838.              mouse event trapping.
  839.  
  840.              MSave allocates a buffer, saves the mouse state in the
  841.              buffer, resets the mouse driver and returns the buffer address.
  842.  
  843.              MRestore restores a specified mouse state and releases the
  844.              buffer.  Both MSave and MRestore assume that you already
  845.              know there is a mouse in the system.
  846.  
  847. Call with:   MSAve: no paramerters
  848.              MRestore: AX = buffer address returned by prior MSave call
  849. Returns:     if CF = 1, AH = MS-DOS error code
  850.              if CF = 0, no error; MSave returns buffer address in AX
  851. Uses:        AX, flags
  852. Example:
  853.  
  854. include asm.inc
  855. extrn   msave:proc, mrestore:proc
  856.  
  857. .data
  858. save_mouse dw 0
  859.  
  860. .code
  861. ; program fragment assumes DS:@data
  862.         .
  863.         .
  864.         .
  865.  
  866. ; save the mouse driver state
  867. ; I've already checked to see if there's a mouse
  868.         call    msave
  869.         jc      dos_error
  870.         mov     save_mouse,ax
  871.         .
  872.         .
  873. ; some other subroutine has messed with the mouse
  874.         mov     ax,save_mouse   ; buffer address from previous MSave
  875.         call    mrestore
  876.         jc      dos_error
  877.  
  878.  
  879.  
  880. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  881.  
  882. PALETTE16:   change palette in EGA, VGA or SVGA 16-color mode
  883.              changing the palette changes the actual color associated
  884.              with a color attribute
  885. Source:      palet16.asm
  886.  
  887. Call with:   BH = color value (see Color16 in SYSTEM.DOC)
  888.              BL = color attribute to map color to (0-0Fh)
  889.              restore default palette with BH = BL = 0FFh
  890. Returns:     nothing
  891. Uses:        nothing
  892. Example:
  893.  
  894. .data
  895. c16     db 3                  ; brightest red
  896.         db 1                  ; dim green
  897.         db 0                  ; no blue
  898.  
  899. .code
  900. ; program fragment assumes DS:@data
  901.         .
  902.         .
  903.         .
  904.         lea   bx,c16
  905.         call  color16
  906.         mov   bh,ah           ; color value in BH
  907.         mov   bl,15           ; color attribute 0Fh
  908.         call  palette16
  909.  
  910.  
  911.  
  912. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  913.  
  914. SYSTEM:      execute a second copy of COMMAND.COM;  optionally runs another
  915.              program.
  916. Source:      system.asm (strlen.asm)
  917.  
  918. Parameters:  ES = PSP segment
  919.              DS:[BX] points to command tail
  920.              if DS:[BX] points to a nul byte, control is transfered
  921.              to the second copy of COMMAND.COM and you get a DOS prompt.
  922.              control is passed back to the calling program when EXIT is
  923.              entered at the DOS prompt.
  924.  
  925.              if DS:[BX] points to an ASCIIZ string with the name of a
  926.              program (and optional command line parameters), the program
  927.              will be executed, and control will pass back to the calling
  928.              program at the termination of the second program.
  929. Returns:     nothing
  930. Uses:        AX
  931. Example:
  932.  
  933. include asm.inc
  934.  
  935. ; I want to go to DOS temporarily to format a 720k disk
  936. extrn   system:proc
  937.  
  938. .data
  939. ; PSP segment is saved here by my startup code
  940. pspseg  dw ?
  941. cmdtail db 'format a: /n:9 /t:80',0
  942.  
  943. .code
  944. ; program fragment assumes DS:@data
  945.         .
  946.         .
  947.         lea     bx,cmdtail    ; DS:[BX] points to command tail
  948.         mov     es,pspseg
  949.         call    system
  950.  
  951.  
  952. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  953.  
  954. USE32K:      limit Hercules equipment to 32k memory (128k on InColor)
  955. USE64K:      allow full 64k on HGC and HGC+ (256k on InColor)
  956. Source:      a$herc.asm
  957.  
  958. Requires Hercules or compatible
  959.  
  960. Call with:   no parameters
  961.              Use32k is equivalent to the Hercules "half" configuration
  962.              Use64k is equivalent to the Hercules "full" configuration
  963.              ASMLIB's default is "half".  Use this configuration if you
  964.              have a 2-monitor system, unless you are using the Hercules
  965.              CGA card. 
  966. Returns:     nothing
  967. Uses:        nothing
  968. Example:     ; in this example I'm determining if a Hercules is installed
  969.              ; and setting the configuration to "full"
  970. extrn  IsHerc:proc
  971. extrn  Use64k:proc
  972. .code
  973.        .
  974.        .
  975.        .
  976.        call  IsHerc
  977.        jc    no_herc
  978.        or    ax,ax
  979.        js    use_only_half   ; use_only_half if HGC is not default monitor
  980.        call  use64k          ; else use all Hercules memory
  981. use_only_half:
  982.  
  983.